#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>
int main()
{
    int n;
    scanf("%d", &n);
    int a[100][100] = { 1,0 };
    int cnt;
    cnt = 1;
    int i, j;
    int p, q;
    p = 0;
    q = 0;
    int sum = 0;
    for (int i = 0; i <= n; i++)
    {
        sum += i;
    }
    if (n % 2 == 0)
    {
        while (cnt < n * n)
        {
            if ((p == 0 || p == n - 1) && q != n - 1)
            {
                a[p][++q] = ++cnt;
            }

            if (p < q)
            {
                for (i = p + 1, j = q - 1; j >= p; i++, j--)
                {
                    a[i][j] = ++cnt;
                }
                p = i - 1;
                q = j + 1;
            }
            else if (p > q)
            {
                for (i = p - 1, j = q + 1; i >= q; j++, i--)
                {
                    a[i][j] = ++cnt;
                }
                p = i + 1;
                q = j - 1;
            }

            if ((q == 0 || q == n - 1) && p != n - 1)
                a[++p][q] = ++cnt;
            if (p == n - 1 && q == n - 1)
                break;
        }
    }
    else if (n % 2 != 0)
    {
        while (cnt < n * n)
        {
            if ((p == 0 || p == n - 1) && q != n - 1 && cnt != (n * n - sum + 1))
            {
                a[p][++q] = ++cnt;
            }

            if (p < q)
            {
                for (i = p + 1, j = q - 1; j >= p; i++, j--)
                {
                    a[i][j] = ++cnt;
                }
                p = i - 1;
                q = j + 1;
            }
            else if (p > q)
            {
                for (i = p - 1, j = q + 1; i >= q; j++, i--)
                {
                    a[i][j] = ++cnt;
                }
                p = i + 1;
                q = j - 1;
            }

            if ((q == 0 || q == n - 1) && p != n - 1)
                a[++p][q] = ++cnt;
            if (p == n - 1 && q == n - 1)
                break;
        }
    }
    for (i = 0; i < n; i++)
    {
        for (j = 0; j < n; j++)
        {
            printf("%d ", a[i][j]);
        }
        printf("\n");
    }
    return 0;
}